package com.ruoyi.web.controller.train;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.train.domain.JyTrainingSchoolCourseMaterial;
import com.ruoyi.train.service.IJyTrainingSchoolCourseMaterialService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 培训课程物资Controller
 *
 * @author aulbrother
 * @date 2024-04-06
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/train/material")
public class JyTrainingSchoolCourseMaterialController extends BaseController {
    private final IJyTrainingSchoolCourseMaterialService jyTrainingSchoolCourseMaterialService;

    /**
     * 查询培训课程物资列表
     */
    @PreAuthorize("@ss.hasPermi('train:material:list')")
    @GetMapping("/list")
    public TableDataInfo list(JyTrainingSchoolCourseMaterial jyTrainingSchoolCourseMaterial) {
        startPage();
        List<JyTrainingSchoolCourseMaterial> list = jyTrainingSchoolCourseMaterialService.selectJyTrainingSchoolCourseMaterialList(jyTrainingSchoolCourseMaterial);
        return getDataTable(list);
    }

    /**
     * 获取培训课程物资详细信息
     */
    @PreAuthorize("@ss.hasPermi('train:material:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(jyTrainingSchoolCourseMaterialService.selectJyTrainingSchoolCourseMaterialById(id));
    }

    /**
     * 修改培训课程物资
     */
    @PreAuthorize("@ss.hasPermi('train:material:edit')")
    @Log(title = "培训课程物资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JyTrainingSchoolCourseMaterial jyTrainingSchoolCourseMaterial) {
        return toAjax(jyTrainingSchoolCourseMaterialService.updateJyTrainingSchoolCourseMaterial(jyTrainingSchoolCourseMaterial));
    }
}
